<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Banner extends MX_Controller {

	public function __construct() {
		parent::__construct();
		
		$this->load->model('banner_model');
		
		
		
	}
	
	public function show($page='INDEX'){
		
		if($page=='INDEX'){
			$data['banner']['all'] = $this->banner_model->getBanner($show=1,$limit=4);
		}
		
		if($page=='INNER'){
			$data['banner']['all'] = $this->banner_model->getBanner($show=2,$limit=3);
		}
		
		//--UPDATE IMPRESSION ----//
		if($data['banner']['all']){
			foreach ($data['banner']['all'] as $banner){
				$id = 	$banner->id."<br>";
				$this->db->where('id', $id);
				$this->db->set('impressions', 'impressions+1', FALSE);
				$this->db->update('banner');
				
			}
		
		}
		
		
		
		$this->load->view('banner',$data);
		
	}
	
	public function click_banner($url='',$id=0){
		
		$url = $this->commoncall->clean_url($url);
		
		$this->db->where('id', $id);
		$this->db->set('clicks', 'clicks+1', FALSE);
		$this->db->update('banner');
		
		redirect('http://'.$url);
		
	}
	
	function bnnrct($id)
	{

		$id = $this->commoncall->get_id(current_url());
		
		$data['banner'] = $this->banner_model->getbnnrcat($id);
		
		
		
		$this->load->view('banner_category',$data);
		
	}
	
	
	function slider()
	{
		$data['slider'] = $this->banner_model->getslider($show=4);
		
		$this->load->view('banner_slider',$data);
		
	}
}	
/* End of file*/	